#include "stm32f10x.h"                  // Device header
#include "OLED.h"
#include "Delay.h"
#include "Serial.h"
#include "SysRTC.h"
#include <time.h>


int main(void)
{
	OLED_Init();
	Serial_Init();
	SysRTC_Init();
	
	OLED_ShowString(1, 1, "Date: YYYY-MM-DD");
	OLED_ShowString(2, 1, "Time: HH:mm:ss");
	OLED_ShowString(3, 1, "TS: ");
	
	struct tm cur;
	uint32_t ts;
	while(1) {
		ts = SysRTC_GetTimestamp();
		SysRTC_GetTime(&cur);
		
		OLED_ShowNum(1, 7, cur.tm_year + 1900, 4);
		OLED_ShowNum(1, 12, cur.tm_mon + 1, 2);
		OLED_ShowNum(1, 15, cur.tm_mday, 2);
		OLED_ShowNum(2, 7, cur.tm_hour, 2);
		OLED_ShowNum(2, 10, cur.tm_min, 2);
		OLED_ShowNum(2, 13, cur.tm_sec, 2);
		OLED_ShowNum(3, 5, ts, 10);
	}
}
